<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
    
    <h:form id="enderecoSearch" styleClass="edit">
    
        <rich:simpleTogglePanel label="#{messages['application.label.searchParameters']}" switchType="ajax">
        
            <s:decorate template="layout/display.xhtml">
                <ui:define name="label"><s:label value="#{messages['application.endereco.label.cep']}" /></ui:define>
                <h:inputText id="idtCep" value="#{enderecoList.endereco.idtCep}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label"><s:label value="#{messages['application.endereco.label.logradouro']}" /></ui:define>
                <h:inputText id="desLogradouro" value="#{enderecoList.endereco.desLogradouro}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label"><s:label value="#{messages['application.endereco.label.bairro']}" /></ui:define>
                <h:inputText id="desBairro" value="#{enderecoList.endereco.desBairro}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label"><s:label value="#{messages['application.endereco.label.cidade']}" /></ui:define>
                <h:inputText id="desCidade" value="#{enderecoList.endereco.desCidade}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label"><s:label value="#{messages['application.endereco.label.estado']}" /></ui:define>
                <h:inputText id="desUf" value="#{enderecoList.endereco.desUf}"/>
            </s:decorate>

        
        </rich:simpleTogglePanel>
        
        <div class="actionButtons">
            <h:commandButton id="search" value="#{messages['application.label.search']}" action="/EnderecoList.xhtml"/>
        </div>
        
    </h:form>
    
    <rich:panel>
        <f:facet name="header"><s:label value="#{messages['application.label.searchResults']}" /></f:facet>
    <div class="results" id="enderecoList">

    <h:outputText value="#{messages['application.endereco.empty']}" 
               rendered="#{empty enderecoList.resultList}"/>
               
    <rich:dataTable id="enderecoList" 
                var="endereco"
              value="#{enderecoList.resultList}" 
           rendered="#{not empty enderecoList.resultList}">
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="#{messages['application.endereco.label.cep']} #{enderecoList.order=='idtCep asc' ? messages.down : ( enderecoList.order=='idtCep desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{enderecoList.order=='idtCep asc' ? 'idtCep desc' : 'idtCep asc'}"/>
                </s:link>
            </f:facet>
            #{endereco.idtCep}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="#{messages['application.endereco.label.logradouro']} #{enderecoList.order=='desLogradouro asc' ? messages.down : ( enderecoList.order=='desLogradouro desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{enderecoList.order=='desLogradouro asc' ? 'desLogradouro desc' : 'desLogradouro asc'}"/>
                </s:link>
            </f:facet>
            #{endereco.desLogradouro}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="#{messages['application.endereco.label.bairro']} #{enderecoList.order=='desBairro asc' ? messages.down : ( enderecoList.order=='desBairro desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{enderecoList.order=='desBairro asc' ? 'desBairro desc' : 'desBairro asc'}"/>
                </s:link>
            </f:facet>
            #{endereco.desBairro}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="#{messages['application.endereco.label.cidade']} #{enderecoList.order=='desCidade asc' ? messages.down : ( enderecoList.order=='desCidade desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{enderecoList.order=='desCidade asc' ? 'desCidade desc' : 'desCidade asc'}"/>
                </s:link>
            </f:facet>
            #{endereco.desCidade}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="#{messages['application.endereco.label.estado']} #{enderecoList.order=='desUf asc' ? messages.down : ( enderecoList.order=='desUf desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{enderecoList.order=='desUf asc' ? 'desUf desc' : 'desUf asc'}"/>
                </s:link>
            </f:facet>
            #{endereco.desUf}
        </h:column>
        <h:column>
            <f:facet name="header"><s:label value="#{messages['application.label.action']}" /></f:facet>
            <s:link view="/#{empty from ? 'Endereco' : from}.xhtml" 
                   value="#{messages['application.label.select']}" 
                      id="endereco">
                <f:param name="enderecoIdtCep" 
                        value="#{endereco.idtCep}"/>
            </s:link>
        </h:column>
    </rich:dataTable>

    </div>
    </rich:panel>
    
    <div class="tableControl">
      
        <s:link view="/EnderecoList.xhtml" 
            rendered="#{enderecoList.previousExists}" 
               value="#{messages.left}#{messages.left} #{messages['application.label.first']}"
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>
        
        <s:link view="/EnderecoList.xhtml" 
            rendered="#{enderecoList.previousExists}" 
               value="#{messages.left} #{messages['application.label.previous']}"
                  id="previousPage">
            <f:param name="firstResult" 
                    value="#{enderecoList.previousFirstResult}"/>
        </s:link>
        
        <s:link view="/EnderecoList.xhtml" 
            rendered="#{enderecoList.nextExists}" 
               value="#{messages['application.label.next']} #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult" 
                    value="#{enderecoList.nextFirstResult}"/>
        </s:link>
        
        <s:link view="/EnderecoList.xhtml" 
            rendered="#{enderecoList.nextExists}" 
               value="#{messages['application.label.last']} #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult" 
                    value="#{enderecoList.lastFirstResult}"/>
        </s:link>
        
    </div>
    
    <s:div styleClass="actionButtons" rendered="#{empty from}">
        <s:button view="/EnderecoEdit.xhtml"
                    id="create" 
                 value="#{messages['application.label.add']}">
            <f:param name="enderecoIdtCep"/>
        </s:button>
    </s:div>
    
</ui:define>

</ui:composition>

